﻿package mortal.game.view.yyZiZuan
{
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class YYZiZuanCategorySpr extends GSprite
    {
        private var _tagList:GTileList;
        private var _selectIndex:int;

        public function YYZiZuanCategorySpr()
        {
            return;
        }// end function

        public function switchTag(param1:int) : void
        {
            this._selectIndex = param1;
            Dispatcher.dispatchEvent(new DataEvent(EventName.YYZiZuanSwicthPanel, this._selectIndex));
            return;
        }// end function

        private function onItemChange(event:Event) : void
        {
            var _loc_2:* = this._tagList.selectedIndex;
            this.switchTag(_loc_2);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._tagList = UIFactory.tileList(0, 0, 870, 42, this);
            this._tagList.columnWidth = 430;
            this._tagList.rowHeight = 30;
            this._tagList.horizontalGap = 1;
            this._tagList.verticalGap = 4;
            this._tagList.setStyle("cellRenderer", YYZiZuanTagCellRender);
            this._tagList.dataProvider = this.getTagListDataProvider();
            this._tagList.direction = GBoxDirection.HORIZONTAL;
            this._tagList.drawNow();
            this._tagList.configEventListener(Event.CHANGE, this.onItemChange);
            return;
        }// end function

        public function refresh() : void
        {
            this._tagList.dataProvider = this.getTagListDataProvider();
            this._tagList.drawNow();
            return;
        }// end function

        private function getTagListDataProvider() : DataProvider
        {
            var _loc_1:* = new DataProvider();
            _loc_1.addItem(YYZiZuanUtil.getCategoryData(YYZiZuanConst.MonthMember));
            _loc_1.addItem(YYZiZuanUtil.getCategoryData(YYZiZuanConst.YearMember));
            return _loc_1;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._tagList.dispose(param1);
            this._tagList = null;
            super.disposeImpl(param1);
            return;
        }// end function

    }
}
